<template>
	<view>
<!-- 		<view class="setting-form">
			<view class="setting-form-input c_757573 ft28">
				<view class="input-tale">真实姓名</view>
				<input placeholder="请输入真实姓名"  placeholder-class="ft28"  v-model="name" />
			</view>
			<view class="setting-form-input c_757573 ft28">
				<view class="input-tale">身份证号</view>
				<input placeholder="请输入身份证号"  placeholder-class="ft28" v-model="card"/>
			</view>
		</view> -->
		<view class="inpu-form-main">
			<view class="input-item">
				<view class="item-zhang item-form-top" >
					<input  placeholder="输入真实姓名" v-model="name"   />
				</view>
				<view class="item-zhang item-form-top">
						<input type="text" placeholder="输入身份证号" v-model="card" />
				</view>
			</view>
			
			<view class="user mt24">
				<view class="text-box">
					<view class="text-box1 flex alcenter ft28 font-bold">
						<view class="icon">
							
						</view>
						<view class="text-box1-text" >
							用户须知
						</view>
					</view>
					<view v-if="userContent" class="mt20" >
						<rich-text :nodes="$fxLink.checkescape2Html(userContent)"></rich-text>
					</view>
					<view v-if="!userContent">
						<view class="text-box2">
							1、请确保<text class='hongse'>实名信息与本人一致</text>	
									如填写错误或使用其他人信息认证导致不能正常提现后果自负
						</view>
						<view class="text-box2">
							2、请确保输入的<text class='heise'>姓名与身份证号匹配</text>			
						</view>
						<view class="text-box2">
							3、<text class='hongse'>未成年</text>
							无法认证本平台，请在监护人协助下进行实名认证。
						</view>
					</view>
				</view>
			</view>
			<view class="form-inputmadin" @click="getRealUser">提交</view>
		</view>

		
	</view>
</template>

<script>
	import * as userApi from '@/api/user'
	export default{
		data(){
			return{
				name:"",
				card:"",
				userContent:""
			}
		},
		onShow() {
			this.getRealNameNotice()
		},
		methods:{
			getRealNameNotice(){
				userApi.getNotice({
					type:2
				})
				.then(result => {
					this.userContent = result.data.content
				})
			},
			hasSpecialStr(str){
					var specialChars= "~·`!！@#$￥%^…&*()（）—-_=+[]{}【】、|\\;:；：'\"“‘,./<>《》?？，。";
					var len=specialChars.length;
					for ( var i = 0; i < len; i++){
							if (str.indexOf(specialChars.substring(i,i+1)) != -1){
									return specialChars.substring(i,i+1);
							}
					}
					return false;
			},
			getRealUser(){
				// this.realUserClose()
				let _this = this;
				let token = uni.getStorageSync("AccessToken")
				if(this.hasSpecialStr(this.name)){
					if(this.hasSpecialStr(this.name) === '.' || '·' || '。'){
						const replaceStr2 = (str, index, char) => {
						 return str.substring(0, index) + char + str.substring(index + 1);
						 }
						let num = this.name.indexOf(this.hasSpecialStr(this.name))
						this.name = replaceStr2(this.name,num,'·')
					}
				}
				userApi.realUser({
						wxapp_id: _this.$wxapp_id,
						name: this.name,
						card:_this.card
					})
					.then(result => {
						_this.user = result.data;
						_this.$toast(result.msg);
						if(result.code == 1){
							setTimeout(() => {
								uni.switchTab({
									url:"/pages/user/index"
								})
				
							},700)
				
						}
					})
					.finally(() => this.isLoading = false)
			},
			realUserClose(){
				this.$refs.luPopupReal.close()
			},
			realUser() {
				if(!this.name){
					this.$toast('请输入姓名')
				}
				if(!this.card){
					this.$toast('请输入身份证号')
					return
				}
				this.$refs.luPopupReal.open('center')
			},
		}
	}
</script>

<style lang="scss">
	page{
		background: #F2F7FA;
	}
	.user{
	    margin-bottom: 24rpx;
	     padding: 32rpx;
	     height: 334rpx;
	     background: #FCFDFD;
	     box-shadow: 0rpx 8rpx 40rpx 0rpx #E8EBEE;
	     border-radius: 0rpx 0rpx 0rpx 0rpx;
	     border: 4rpx solid #FFFFFF;
	     box-sizing: border-box;
	     .user-top{
	         height: 42rpx;
	         font-family: PingFang SC, PingFang SC;
	         font-weight: 600;
	         font-size: 30rpx;
	         color: #333333;
	         line-height: 35rpx;
	         text-align: left;
	         font-style: normal;
	         text-transform: none;
	     }
	     .user-text{
	         font-family: PingFang SC, PingFang SC;
	         font-weight: 400;
	         font-size: 26rpx;
	         color: #333333;
	         line-height: 44rpx;
	         text-align: left;
	         font-style: normal;
	         text-transform: none;
	     }
	}
</style>